package ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.exportRFCPanel.exportRFCPanelSubs;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.exportRFCPanel.ExportRFCPanel;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.exportRFCPanel.listeners.ShowNewsFromTableActionlistener;

public class ExportRFCNewsPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private JLabel title;
	private ExportNewsTable exportNewsTable;
	private ExportRFCPanel exportRFCPanel;

	public ExportRFCNewsPanel(ExportRFCPanel exportRFCPanel) {

		this.setPreferredSize(new Dimension(250, 290));

		this.title = new JLabel("Benachrichtigungen");

		this.exportRFCPanel = exportRFCPanel;

		this.setLayout(new BorderLayout());

		this.add(this.title, BorderLayout.NORTH);

		this.add(this.setupNewsList());

	}

	private JScrollPane setupNewsList() {

		this.exportNewsTable = new ExportNewsTable();
		this.exportNewsTable
				.addMouseListener(new ShowNewsFromTableActionlistener(exportRFCPanel,
						exportNewsTable));

		JScrollPane scrollPane = new JScrollPane(this.exportNewsTable);
		scrollPane
				.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

		return scrollPane;
	}

	public ExportNewsTable getExportNewsTable() {
		return exportNewsTable;
	}

	public JLabel getTitle() {
		return title;
	}

}
